//package com.gxuwz.stats.controller;
//
//import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.ExcelWriter;
//import com.alibaba.excel.write.metadata.WriteSheet;
//import com.gxuwz.stats.entity.ResearchProject;
//import com.gxuwz.stats.entity.TotalWork;
//import com.gxuwz.stats.service.ExcelImportService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.ArrayList;
//
//@RestController
//@RequestMapping("/sumImportData")
//@Slf4j
//public class ImportController {
//
//    @Autowired
//    private ExcelImportService importService;
//
//    @PostMapping("/excel")
//    public ResponseEntity<?> importExcel(@RequestParam("file") MultipartFile file) {
//        try {
//            if (file.isEmpty()) {
//                return ResponseEntity.badRequest().body("请选择要上传的文件");
//            }
//
//            String fileName = file.getOriginalFilename();
//            if (!fileName.endsWith(".xlsx")) {
//                return ResponseEntity.badRequest().body("只支持.xlsx格式的文件");
//            }
//
//            importService.importExcelData(file);
//            return ResponseEntity.ok("数据导入成功");
//        } catch (Exception e) {
//            log.error("导入失败", e);
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
//                    .body("导入失败：" + e.getMessage());
//        }
//    }
//
////    @GetMapping("/sumImport")
////    public void importData(HttpServletResponse response) throws IOException {
////        // 设置响应头
////        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
////        response.setCharacterEncoding("utf-8");
////
////        // 创建 ExcelWriter
////        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
////
////        // 总工作量表
////        WriteSheet totalWorkSheet = EasyExcel.writerSheet(0, "总工作量")
////                .head(TotalWork.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), totalWorkSheet);
////
////        // 科研项目工作量表
////        WriteSheet researchProjectSheet = EasyExcel.writerSheet(1, "科研项目工作量")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), researchProjectSheet);
////
////        WriteSheet academicWorkSheet = EasyExcel.writerSheet(2, "学术著作")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), academicWorkSheet);
////
////        WriteSheet decisionConsultSheet = EasyExcel.writerSheet(3, "决策咨询类")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), decisionConsultSheet);
////
////        WriteSheet creativeAchievementSheet = EasyExcel.writerSheet(4, "创作成果类")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), creativeAchievementSheet);
////
////        WriteSheet intellectualPropertySheet = EasyExcel.writerSheet(5, "知识产权类")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), intellectualPropertySheet);
////
////        WriteSheet achievementTransferSheet = EasyExcel.writerSheet(6, "成果转化类")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), achievementTransferSheet);
////
////        WriteSheet researchAwardNatureSheet = EasyExcel.writerSheet(7, "科研奖项（自然科学）")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), researchAwardNatureSheet);
////
////        WriteSheet researchAwardHumanitiesSheet = EasyExcel.writerSheet(8, "科研奖项（人文社科）")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), researchAwardHumanitiesSheet);
////
////        WriteSheet networkCultureSheet = EasyExcel.writerSheet(9, "网络文化成果")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), networkCultureSheet);
////
////        WriteSheet academicPaperSheet = EasyExcel.writerSheet(10, "学术论文")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), academicPaperSheet);
////
////        WriteSheet scientificActivitySheet = EasyExcel.writerSheet(11, "科技活动")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), scientificActivitySheet);
////
////        WriteSheet platformSheet = EasyExcel.writerSheet(12, "重要平台")
////                .head(ResearchProject.class)
////                .build();
////        excelWriter.write(new ArrayList<>(), platformSheet);
////
////        // 完成写入
////        excelWriter.finish();
////    }
//}
